package cn.edu.scau.cmi.zhangweiming.factory;
import cn.edu.scau.cmi.zhangweiming.simpleFactoryMethod.domain.*;
import java.net.URL;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.ResourceBundle;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;

public class Factory_controller {
	   @FXML
	   private Button pork,beef,chicken;
	   @FXML
	   private TextField Textfield;
	   @FXML
	   private TextArea	Textarea;
	   
	   public void make(ActionEvent event) {
		   Object obj=event.getSource();
		   String text=Textfield.getText();
		   if(obj==pork) {
			   MeatFactory meat=new PorkMeatFactory();
			   Pork pork=(Pork)meat.getMeat();
			   pork.setName(text);
			   Textarea.appendText("pork"+pork.getName()+" ready");
			   Textarea.appendText("\n");
		   }
		   if(obj==beef) {
			   MeatFactory meat=new BeefMeatFactory();
			   Beef beef=(Beef)meat.getMeat();
			   beef.setName(text);
			   Textarea.appendText("beef"+beef.getName()+" ready");
			   Textarea.appendText("\n");
		   }
		   if(obj==chicken) {
			   MeatFactory meat=new ChickenMeatFactory();
			   Chicken chicken=(Chicken)meat.getMeat();
			   chicken.setName(text);
			   Textarea.appendText("chicken"+chicken.getName()+" ready");
			   Textarea.appendText("\n");
		   }
	   }
}
